fuzz/x86_emulate: Fix afl-harness batch mode file pointer leak
authorGeorge Dunlap <george.dunlap@citrix.com>
Fri, 13 Oct 2017 08:36:00 +0000 (09:36 +0100)
committerGeorge Dunlap <george.dunlap@citrix.com>
Fri, 27 Oct 2017 13:44:05 +0000 (14:44 +0100)
commitd525519bedbcb3fb7b9cc297e352a35124681850
treeee295123c9a84e498287e5c4b1f550a8b342606c
parent3285e75dea89afb0ef5b3ee39bd15194bd7cc110
fuzz/x86_emulate: Fix afl-harness batch mode file pointer leak

Changeset 2b1cde7783 introduced "batch mode" to afl-harness, which allowed
the handling of several inputs in sequence.

Unfortunately, it introduced a file pointer leak when the file was
larger than the maximum size.  Restructure the code to always close fp
if we opened it.

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Release-acked-by: Julien Grall <julien.grall@linaro.org>
tools/fuzz/x86_instruction_emulator/afl-harness.c